package per.kongtouxu.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import per.kongtouxu.domain.pojo.RegInfo;
import per.kongtouxu.service.Impl.RegInfoServiceImpl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/regMgr")
public class RegMgrController {
    @Autowired
    private RegInfoServiceImpl regInfoService;
    //查询奖励
    @RequestMapping("/findRegAward")
    public @ResponseBody Integer findRegAward(HttpServletRequest req, HttpServletResponse resp)throws Exception{
        RegInfo regInfo = regInfoService.findRegInfoById(1);
        System.out.println("得到的分数:"+regInfo);
        return regInfo.getRegScore();
    }
    //修改奖励
    @RequestMapping("/updateRegAward")
    public @ResponseBody Boolean updateRegAward(HttpServletRequest req, HttpServletResponse resp)throws Exception{
        String award = req.getParameter("award");
        regInfoService.updateRegInfoById(1,Integer.parseInt(award));
        return true;
    }
}
